﻿// Copyright (c) Kona Framework Team. All rights reserved.
// For continued development and updates, visit http://www.codeplex.com/kona
// For a copy of the license please vist: http://www.codeplex.com/kona/license
using System.Collections.Generic;
using System.Configuration;
using Kona.Data;

namespace Kanaka.ResourceAccess.Reports
{
    public class UsCustomerCountsByStateReport
    {
        public UsCustomerCountsByStateReport(int fiscalYear)
        {
            this.FiscalYear = fiscalYear;
        }

        public int FiscalYear { get; private set; }

        public IEnumerable<StateProvinceMonthlyCustomerCounts> StateProvinceMonthlyCustomerCounts
        {
            get
            {
                string OlapConnectionString = ConfigurationManager.ConnectionStrings["CustomerCube"].ConnectionString;

                // should cache this result
                IEnumerable<StateProvinceMonthlyCustomerCounts> Results;
                using (AdoMdConnection Connection1 = new AdoMdConnection(OlapConnectionString))
                {
                    Reports.Queries.UsCustomerCountsByStateForFiscalYearQuery Query =
                        new Reports.Queries.UsCustomerCountsByStateForFiscalYearQuery(Connection1,
                                                                      new Queries.Parameters.FiscalYear(this.FiscalYear));
                    Results = Query.Execute();
                }
                return Results;
            }
        }

    }
}
